{extends file="../home.html"}
{block name="title"}{$head_title}{/block}
{block name="css"}
<link rel="stylesheet" type="text/css" href="/Public/Css/front/front_css/live.css">

<style type="text/css">
	body{
		background-color: #f3f3f3;
	}
	.w1{
		font-size: 10px;
		top:4rem;
		text-align: center;
	}
</style>
{/block}
{block name="content"}
<div class="title">
	<span class="go_back"></span>
	意见反馈
</div>

<textarea  class="feedback" name="content" maxlength="50" placeholder="请输入您的宝贵意见或者建议，我们会认真对待的～"></textarea>
<span class="now_num">0</span>
<span class="submit">提交</span>

<div class="veri_sent">
	<span class="tanchuang_success"></span>
	<span class="w">验证码已发送</span>
</div>

<!--验证码错误弹框-->
<div class="veri_wrong">
	<span class="tanchuang_defeat"></span>
	<span class="w w1">验证码错误</span>
</div>
{/block}
{block name="js"}
{literal}
<script>
	var is_click =false;
	$('.submit').on('click',function () {
		if(is_click == true) return;
		is_click = true;
		var content = $('.feedback').val();
		console.log(content);
		if(!content){
			//弹窗提示 不为空
			$('.veri_wrong').find('.w').html('内容不能为空！');
			$('.veri_wrong').fadeIn(1500);
			$('.veri_wrong').fadeOut(1500);
			is_click = false;
			return;
		}
		console.log(content.length);
		if(content.length < 20){
			//弹窗提示 不能少于20个字
			$('.veri_wrong').find('.w').html('不能少于20个字！');
			$('.veri_wrong').fadeIn(1500);
			$('.veri_wrong').fadeOut(1500);
			is_click = false;
			return;
		}

		if(content.length > 50){
			//弹窗提示 不能多于50个字
			$('.veri_wrong').find('.w').html('不能多于50个字！');
			$('.veri_wrong').fadeIn(1500);
			$('.veri_wrong').fadeOut(1500);
			is_click = false;
			return;
		}
		$.ajax({
			type:'post',
			url:'/FrontUserCenter/feedback',
			data:{content:content},
			success:function (data) {
				if(data.code == 1){
					//弹窗成功

					$('.veri_sent').find('.w').html(data.msg);
					$('.veri_sent').fadeIn(1500);
					$('.veri_sent').fadeOut(1500);

					//成功后返回!
					setTimeout(function () {
						if(!is_wechat()){
							native_listen('back');
						}else{
							history.go(-1);
						}
					},3000)
				}else{
					//弹窗失败
					$('.veri_wrong').find('.w').html(data.msg);
					$('.veri_wrong').fadeIn(1500);
					$('.veri_wrong').fadeOut(1500);

				}

				is_click = false;
			}
		})
	})

$('.now_num').html($('.feedback').val().length+'/50');
	$('.feedback').bind('input propertychange',function(){
	
		var num = $('.feedback').val().length;
		
		
		console.log(num);

		$('.now_num').html(num+'/50');
		
		
	});

</script>
{/literal}
{/block}
